﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using Artizan.Utility;

/// <summary>
/// Summary description for Lookup
/// </summary>
public class Lookup
{
    public int LookupID
    {
        get;
        set;
    }
    
    public string LookupGroup
    {
        get;
        set;
    }
    public string LookupText
    {
        get;
        set;
    }

	public Lookup()
	{		
	}

    public static List<Lookup> GetLookupGroup(string groupName)
    {
        List<Lookup> groupList = new List<Lookup>();
        using (SqlConnection conn = new SqlConnection(Globals.GetConnectionString()))
        {
            using (SqlCommand cmd = new SqlCommand("PomLookupSelectGroup", conn))
            {
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@pGroupName", groupName);
                cmd.Connection.Open();

                DataTable dt = new DataTable("DtPropertyList");
                IDataReader reader = cmd.ExecuteReader();
                dt.Load(reader);
                cmd.Connection.Close();
                groupList = FieldMapper.DataTableToList<Lookup>(ref dt);
            }
        }
        return groupList;
    }
}